home *** CD-ROM | disk | FTP | other *** search
/ .net (Turkey) 1998 March / .net Internet Dergisi - CD 5.iso / mac / CON_BM / 00294_Script_294 < prev    next >
Text File  |  1997-11-07  |  2KB  |  58 lines

  1. --Volume control bit
  2.  
  3.  
  4. -- this gets a decimal value for the position of the handle on the slide.
  5. -- the position is calculated as the location of the handle 
  6. -- - half it's width divided by the total length of the slide to a 
  7. -- value of 1 decimal point. 
  8. -- Finer results can be achieved with a longer slide and/or a higher 
  9. -- floatPrecision value. 
  10. -- The code is independent of the size of the slide. You're free 
  11. -- to create any size slide to fit your needs.
  12.  
  13. -------------
  14.  
  15. on sliderV slideSprite,theFld
  16.   -- this handler deals with vertical sliders
  17.   set handleSprite = the clickOn
  18.   puppetSprite handleSprite, true
  19.   set h =  the height of sprite slideSprite
  20.   -- this is the basis for calculating the value that 
  21.   -- the slider returns
  22.   set the floatPrecision to 1
  23.   -- the floatPrecision sets the decimal value for the 
  24.   -- calculation below. 
  25.   repeat while the stillDown
  26.     set the locV of sprite handleSprite = constrainV(slideSprite, (the mouseV - 10))
  27.    updateStage  
  28.   -- this just places the handle on the slide. It's 
  29.   -- constrained to move only along the slide sprite.
  30.   set vPos = the locV of sprite handleSprite
  31.   -- get the final location of the handle
  32.   --    set howFarV = ((float(the bottom of sprite slideSprite - vPos) / h) * 100)
  33.   --    put howFarV into field theFld
  34.   -- this calculation returns a value from 0 to 100
  35.   set howFarV = integer ((float(the bottom of sprite slideSprite - vPos) / h) * 255)
  36.   if the movieName = "con_mm" then
  37.     set the volume of sound 2 to howFarV
  38.   else
  39.     set the volume of sprite 48 to howFarV
  40.   end if
  41.   
  42.   put howFarV into field theFld
  43.   -- this calculation returns a value from 0 to 255 in 
  44.   -- integers, no decimal places
  45.    end repeat
  46.   updatestage
  47. end 
  48.  
  49.  
  50. -- the position is calculated as the location of the handle 
  51. -- - half it's height divided by the total length of the 
  52. -- slide to a value of 1 decimal point. 
  53. -- Finer results can be achieved with a longer slide and/or 
  54. -- a higher floatPrecision value.
  55. -- The code is independent of the size of the slide. You're 
  56. -- free to create any size slide to fit your needs.
  57.  
  58. -------------